package ss.pku.jsa.type.views;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;

public class JqualOutputView extends ViewPart {
	private TableViewer viewer;

	public void createPartControl(Composite parent) {
		this.viewer = new TableViewer(parent, 770);
		this.viewer.setContentProvider(new ViewContentProvider());
		this.viewer.setLabelProvider(new ViewLabelProvider());
		this.viewer.setInput(getViewSite());
	}

	// private void showMessage(String message)
	// {
	// MessageDialog.openInformation(
	// this.viewer.getControl().getShell(),
	// "JQual Output",
	// message);
	// }

	public void setFocus() {
		this.viewer.getControl().setFocus();
	}

	class ViewContentProvider implements IStructuredContentProvider {
		ViewContentProvider() {
		}

		public void inputChanged(Viewer v, Object oldInput, Object newInput) {
		}

		public void dispose() {
		}

		public Object[] getElements(Object parent) {
			return new String[] { "One", "Two", "Three" };
		}
	}

	class ViewLabelProvider extends LabelProvider implements
			ITableLabelProvider {
		ViewLabelProvider() {
		}

		public String getColumnText(Object obj, int index) {
			return getText(obj);
		}

		public Image getColumnImage(Object obj, int index) {
			return getImage(obj);
		}

		public Image getImage(Object obj) {
			return PlatformUI.getWorkbench().getSharedImages()
					.getImage("IMG_OBJ_ELEMENTS");
		}
	}
}

